/*
 * Copyright (C) 2017 Baidu, Inc. All Rights Reserved.
 */
package com.kfm.hotel.util;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * Json工具类.
 */
public class GsonUtils {
    private static ObjectMapper jsonmapper=new ObjectMapper();

    public static String toJson(Object value) throws JsonProcessingException {
        //将对象转换为json
        return jsonmapper.writeValueAsString(value);

    }

    public static <T> T fromJson(String json, Class<T> classOfT) throws JsonProcessingException {
        return jsonmapper.readValue(json,classOfT);
    }
}
